<?php foreach ($memes as $i => $meme): ?>
    <?php $this->renderPartial('//partials/meme', array('meme' => $meme, 'single' => $single)) ?>
    <?php echo $i == 3 ? Settings::value('ad2') : ''; ?>
<?php endforeach; ?>